package co.uk.j_wp.games.topdowngame.entity;

import co.uk.j_wp.games.topdowngame.Screen;
import co.uk.j_wp.games.topdowngame.level.Level;
import co.uk.j_wp.games.topdowngame.tile.Tile;

public class Entity {
	protected long tick = 0;

	protected int width = 1;
	protected int height = 1;

	public int posx = 0;
	public int posy = 0;

	protected Level level;

	public Entity(Level l) {
		this.level = l;
	}

	public void draw(Screen s, int xo, int yo) {
	}

	public void tick() {
	}

	protected boolean canMove() {
		return getTileisPassable(posx, posy) && getTileisPassable(posx + width - 1, posy + height - 1) && getTileisPassable(posx, posy + height - 1) && getTileisPassable(posx + width - 1, posy);
	}

	public boolean getTileisPassable(int x, int y) {
		Tile newTile = level.getTileAtCoords(x, y);
		if (newTile != null) {
			return newTile.isPassable();
		} else {
			return true;
		}

	}
}
